package com.servlet;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.domain.AllCart;
import com.domain.User;
import com.service.CarService;

/**
 * 
 * 功能描述：购物车的Servlet  从数据库取数据
 * 
 * Version： 1.0
 * 
 * date： 2016年6月24日 上午10:55:53
 * 
 * @author：XiaoBingBy
 *
 */
public class shoppingServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    public shoppingServlet() {
        super();
    }

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		//获取用户
		HttpSession session = request.getSession();
		User MyUser = (User) session.getAttribute("MyUser");
		
		CarService carService = new CarService();	//业务方法
		List<AllCart> allCatInfo = carService.getCatInfo(MyUser.getUsername());	//业务方法 获取购物车商品

		session.setAttribute("allCart", allCatInfo);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
